#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <memory>
using namespace std;

class A
{
public:
	~A()
	{
		cout << "~A()" << endl;
	}
private:
	int _a;
};

template<class T>
struct deletearr
{
	void operator()(const T* a)
	{
		cout << "deletearr()" << endl;

		delete[] a;
	}
};

template<class T>
struct freeptr
{
	void operator()(T* a)
	{
		cout << "freeptr" << endl;

		free(a);
	}
};

struct closefile
{
	void operator()(FILE* f)
	{
		cout << "closefile" << endl;

		fclose(f);
	}
};


int main()
{
	shared_ptr<A> sp1(new A);
	shared_ptr<A> sp2(new A[5], deletearr<A>());
	shared_ptr<A> sp3((A*)malloc(sizeof(A)), freeptr<A>());
	shared_ptr<FILE> sp4(fopen("text.txt", "w"), closefile());


	return 0;
}